classdef PopulationA < Population
    %Populacja z wzorcem zmieniajacym sie raz na generacje
    %Tam gdzie we wzorcu 0 tam polaczenia od jednego z rozicow
    %tam gdzie 1 - od drugniego, drugie odwrotnie. Bez mutacji
    %szansa na bycie rodzicem proporcjonalna do pozycji w rankingu
    
    
    
    properties
        %pattern
        %next_generation
    end
    
    methods
        function obj = PopulationA(size, IndividualsClass)
            obj = obj@Population(size, IndividualsClass);
            obj.Crosser = SimpleCrosser();
            obj.GenerationChanger = FullGenerationChanger();
            obj.ParentChooser = RankParentChooser();
        end
        
        function generate_random_pattern(obj)
            density = 0.5; %TODO: refactor
            obj.pattern = random_connections( obj.individuals(1).stops.number, density ); %I don't like this. TODO: find better way to get number of stops
        end
        
        
        

%         function [child1, child2] = cross( obj, p1, p2 )
%             child1 = obj.IndividualsClass.new(); %have to add .new static function to Individual implementation
%             child2 = obj.IndividualsClass.new();
%             
%             [conn1, conn2] = cross_connections( p1.connections, p2.connections, obj.pattern );
%             child1.connections = conn1;           
%             child2.connections = conn2;
%         end
%         
%         function [p1, p2] = choose_parents(obj)
%             if ~obj.sorted
%                 obj.sort();
%             end
%             p1 = obj.individuals( rank_proportional_rand_idx(obj.size) );
%             p2 = obj.individuals( rank_proportional_rand_idx(obj.size) );
%         end
%         
%         function to_next_generation(obj)
%             obj.generate_random_pattern
%             obj.compute_objectives
%             for k=1:(ceil(obj.size/2)) % to sie wywala przy nieparzystej liczbie osobnikow - kolejna genracja daje size-1 osobniokow
%                 obj.create_children();
%             end
%             obj.individuals = obj.next_generation;
%             obj.next_generation = [];
%             obj.sorted = false; %TODO: refactor - should not be need to remember to set this to false
%         end
    end
    
end

